package com.mirror.llk.view;

import java.util.Map;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.mirror.llk.R;
import com.mirror.llk.task.ThemePublishTask;

public class ViewHandler {

	public View transfer(Context context, int resource, View convertView, Map<String, ?> data) {
		switch (resource) {
			case R.layout.theme_choose_item:
				return getThemeChooseView(context, data, convertView);
			case R.layout.theme_download_item:
				return getThemeOfficialView(data, convertView);
			default:
		}
		return convertView;
	}

	private synchronized View getThemeChooseView(final Context context, Map<String, ?> data, View convertView) {
		final Long localId = (Long) data.get(R.id.theme_localId);
		Button btnPublish = (Button) convertView.findViewById(R.id.btn_themeChoose_publish);
		btnPublish.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View paramView) {
				new ThemePublishTask(context, localId).execute();
			}
		});
		return convertView;
	}

	private synchronized View getThemeOfficialView(Map<String, ?> data, View convertView) {
		return convertView;
	}
}
